/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('quickbi-public', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AddUserTagMetaRequest {
  tagDescription?: string(name='TagDescription'),
  tagName?: string(name='TagName'),
}

model AddUserTagMetaResponseBody = {
  requestId?: string(name='RequestId', example='D787E1A3-A93C-424A-B626-C2B05DF8D885'),
  result?: string(name='Result', example='0822a7d9-****-****-****-f20163ab9b0d'),
  success?: boolean(name='Success', example='true'),
}

model AddUserTagMetaResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AddUserTagMetaResponseBody(name='body'),
}

async function addUserTagMetaWithOptions(request: AddUserTagMetaRequest, runtime: Util.RuntimeOptions): AddUserTagMetaResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.tagDescription)) {
    query['TagDescription'] = request.tagDescription;
  }
  if (!Util.isUnset(request.tagName)) {
    query['TagName'] = request.tagName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'AddUserTagMeta',
    version = '2020-08-02',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function addUserTagMeta(request: AddUserTagMetaRequest): AddUserTagMetaResponse {
  var runtime = new Util.RuntimeOptions{};
  return addUserTagMetaWithOptions(request, runtime);
}

model DeleteUserTagMetaRequest {
  tagId?: string(name='TagId', example='pop_001'),
}

model DeleteUserTagMetaResponseBody = {
  requestId?: string(name='RequestId', example='D787E1A3-A93C-424A-B626-C2B05DF8D885'),
  result?: boolean(name='Result', example='true'),
  success?: boolean(name='Success', example='true'),
}

model DeleteUserTagMetaResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteUserTagMetaResponseBody(name='body'),
}

async function deleteUserTagMetaWithOptions(request: DeleteUserTagMetaRequest, runtime: Util.RuntimeOptions): DeleteUserTagMetaResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.tagId)) {
    query['TagId'] = request.tagId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteUserTagMeta',
    version = '2020-08-02',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function deleteUserTagMeta(request: DeleteUserTagMetaRequest): DeleteUserTagMetaResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteUserTagMetaWithOptions(request, runtime);
}

model QueryUserTagMetaListResponseBody = {
  requestId?: string(name='RequestId', example='D787E1A3-A93C-424A-B626-C2B05DF8D885'),
  result?: [ 
    {
      tagDescription?: string(name='TagDescription'),
      tagId?: string(name='TagId', example='pop_001'),
      tagName?: string(name='TagName'),
    }
  ](name='Result'),
  success?: boolean(name='Success', example='true'),
}

model QueryUserTagMetaListResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryUserTagMetaListResponseBody(name='body'),
}

async function queryUserTagMetaListWithOptions(runtime: Util.RuntimeOptions): QueryUserTagMetaListResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'QueryUserTagMetaList',
    version = '2020-08-02',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryUserTagMetaList(): QueryUserTagMetaListResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryUserTagMetaListWithOptions(runtime);
}

model QueryUserTagValueListRequest {
  userId?: string(name='UserId', example='fe67f61a35a94b7da1a34ba174a7****'),
}

model QueryUserTagValueListResponseBody = {
  requestId?: string(name='RequestId', example='D787E1A3-A93C-424A-B626-C2B05DF8D885'),
  result?: [ 
    {
      tagId?: string(name='TagId', example='pop_001'),
      tagName?: string(name='TagName'),
      tagValue?: string(name='TagValue'),
    }
  ](name='Result'),
  success?: boolean(name='Success', example='true'),
}

model QueryUserTagValueListResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryUserTagValueListResponseBody(name='body'),
}

async function queryUserTagValueListWithOptions(request: QueryUserTagValueListRequest, runtime: Util.RuntimeOptions): QueryUserTagValueListResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryUserTagValueList',
    version = '2020-08-02',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryUserTagValueList(request: QueryUserTagValueListRequest): QueryUserTagValueListResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryUserTagValueListWithOptions(request, runtime);
}

model UpdateUserTagMetaRequest {
  tagDescription?: string(name='TagDescription'),
  tagId?: string(name='TagId', example='e82f6c6c0333431bad0225b2f85e****'),
  tagName?: string(name='TagName'),
}

model UpdateUserTagMetaResponseBody = {
  requestId?: string(name='RequestId', example='D787E1A3-A93C-424A-B626-C2B05DF8D885'),
  result?: boolean(name='Result', example='true'),
  success?: boolean(name='Success', example='true'),
}

model UpdateUserTagMetaResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: UpdateUserTagMetaResponseBody(name='body'),
}

async function updateUserTagMetaWithOptions(request: UpdateUserTagMetaRequest, runtime: Util.RuntimeOptions): UpdateUserTagMetaResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.tagDescription)) {
    query['TagDescription'] = request.tagDescription;
  }
  if (!Util.isUnset(request.tagId)) {
    query['TagId'] = request.tagId;
  }
  if (!Util.isUnset(request.tagName)) {
    query['TagName'] = request.tagName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UpdateUserTagMeta',
    version = '2020-08-02',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function updateUserTagMeta(request: UpdateUserTagMetaRequest): UpdateUserTagMetaResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateUserTagMetaWithOptions(request, runtime);
}

model UpdateUserTagValueRequest {
  tagId?: string(name='TagId', example='pop_001'),
  tagValue?: string(name='TagValue'),
  userId?: string(name='UserId', example='fe67f61a35a94b7da1a34ba174a7****'),
}

model UpdateUserTagValueResponseBody = {
  requestId?: string(name='RequestId', example='46e5374665ba4b679ee22e2a29270'),
  result?: boolean(name='Result', example='true'),
  success?: boolean(name='Success', example='true'),
}

model UpdateUserTagValueResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: UpdateUserTagValueResponseBody(name='body'),
}

async function updateUserTagValueWithOptions(request: UpdateUserTagValueRequest, runtime: Util.RuntimeOptions): UpdateUserTagValueResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.tagId)) {
    query['TagId'] = request.tagId;
  }
  if (!Util.isUnset(request.tagValue)) {
    query['TagValue'] = request.tagValue;
  }
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UpdateUserTagValue',
    version = '2020-08-02',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function updateUserTagValue(request: UpdateUserTagValueRequest): UpdateUserTagValueResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateUserTagValueWithOptions(request, runtime);
}

